using System;
using System.Windows.Input;
using Phoenix;
using Phoenix.Commands;

namespace TodoApp.Features.Tasks
{
    public class CreateViewModel : ViewModelBase
    {
        public CreateViewModel()
        {
            CreateCommand = Controller<TasksController>().InvokeActionCommand(c => c.Create(Title, DueDate));
            CancelCommand = new DelegateCommand(Cancel);
        }

        void Cancel()
        {
            Context.CompletionSource.SetResult(new CreateTaskResult(false, null));
            NavigateBack();
        }

        public string Title { get; set; }
        public DateTime? DueDate { get; set; }

        public ICommand CreateCommand { get; private set; }
        public ICommand CancelCommand { get; private set; }
    }
}